package cloud.daodao.storm.common.user.api;

import cloud.daodao.storm.common.constant.AppConstant;
import cloud.daodao.storm.common.model.*;
import cloud.daodao.storm.common.user.constant.UserConstant;
import cloud.daodao.storm.common.user.model.user.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PostExchange;

/**
 * @author DaoDao
 */
@Tag(name = "UserApi", description = "用户接口")
@HttpExchange(url = AppConstant.API)
public interface UserApi {

    @Operation(summary = "用户信息", description = "@DaoDao header 中传入 token 信息，获取用户信息")
    @PostExchange(url = UserConstant.USER_INFO)
    Response<UserData> userInfo(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorization, @RequestBody @Valid Request<No> request);

    @Operation(summary = "查询用户", description = "@DaoDao 传入 id 查询用户信息")
    @PostExchange(url = UserConstant.USER_SELECT)
    Response<UserData> userSelect(@RequestBody @Valid Request<UserSelect> request);

    @Operation(summary = "写入用户", description = "@DaoDao 传入用户信息，新增或更新一个用户")
    @PostExchange(url = UserConstant.USER_UPSERT)
    Response<UserData> userUpsert(@RequestBody @Valid Request<UserUpsert> request);

    @Operation(summary = "搜索用户", description = "@DaoDao 传入用户信息，搜索用户列表")
    @PostExchange(url = UserConstant.USER_SEARCH)
    Response<PageData<UserData>> userSearch(@RequestBody @Valid Request<PageParam<UserSearch>> request);

    @Operation(summary = "更新信息", description = "@DaoDao header 中传入 token 信息，更新自己的用户信息")
    @PostExchange(url = UserConstant.USER_UPDATE)
    Response<UserData> userUpdate(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorization, @RequestBody @Valid Request<UserUpdate> request);

}
